import errors from "restify-errors";
import { EntityRepository } from "typeorm";

import { Power } from "@src/apps/goods/entities/power.entity"
import { ValidateRepository } from "@src/lib/db/postgres/validate.repository";

@EntityRepository(Power)
export class PowerRepository extends ValidateRepository<Power> {
    async getIP(): Promise<string|undefined> {
        const user = await this.findOne(0);
        if (user === undefined){
            return user;
        }
        return user.ip;
    }
    async getAll(): Promise<Power[]|undefined|string> {
        const users = await this.find();
        if (users === undefined){
            return 'not found goods';
        }
        return users;
    }
}